#include <soar.h>

int main(int argc, char *argv[])
{
    char msg[BUFFER_SIZE];
    char code[BUFFER_SIZE*2];
    int code_size;
    char plain[BUFFER_SIZE];
    int plain_size;
    int res;

    ossl_init();

    strcpy(msg,
            "东风袅袅泛崇光，香雾空蒙月转廊。"
            "只恐夜深花睡去，故烧高烛照红妆。");
    if((res=ossl_encode(OSSL_ENCODE_BASE64,
                    (unsigned char *)msg, strlen(msg),
                    code, &code_size)))
    {
        printf("ossl_encode fail, res:%d\n", res);
        return(-1);
    }
    printf("%s\n", code);
    base64_unwrap(code, code);
    printf("unwrap:\n%s\n", code);
    base64_wrap(code, code);
    printf("wrap:\n%s\n", code);
    res=ossl_decode(OSSL_ENCODE_BASE64,
                    code, strlen(code),
                    (unsigned char *)plain, &plain_size);
    if(res || plain_size != strlen(msg))
    {
        printf("ossl_decode fail, size:%d res:%d\n",
                plain_size, res);
        return(-1);
    }
    printf("%s\n", plain);

    ossl_clean();

    return(0);
}
